<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content="天地图"/>
    <meta name="viewport" content="height=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <title>天地图－地图API－范例－H5定位</title>
    <script type="text/javascript" src="http://api.tianditu.com/api?v=4.0"></script>
    <style type="text/css">body,html{width:100%;height:100%;margin:0;font-family:"Microsoft YaHei"}#mapDiv{width:100%;height:100%}input,b,p{margin-left:5px;font-size:14px}</style>
    <script>
        var map;
        var zoom = 12;
        function onLoad() {
            //初始化地图对象
            map = new T.Map("mapDiv");
            //设置显示地图的中心点和级别
            map.centerAndZoom(new T.LngLat(116.40969, 38.89945), zoom);

            navigator.geolocation.getCurrentPosition(function(position){

                var y = position.coords.longitude;//经度
                var x = position.coords.latitude;//维度
                console.log(y,x);
                // //设置显示地图的中心点和级别
                // map.centerAndZoom(new T.LngLat(y,x),zoom);
                // //允许鼠标滚轮缩放地图
                // // map.enableHandleMouseScroll();

                // //向地图上添加自定义标注
                // var marker = new T.Marker(new T.LngLat(y,x));
                // //向地图上添加标注
                // map.addOverLay(marker);
            });
        }
    </script>
</head>
<body onLoad="onLoad()">
<div id="mapDiv"></div>
</body>
</html>